#include "myScreen.h"

MyScreen::MyScreen()
{
}

MyScreen::~MyScreen()
{
}

void MyScreen::Render()
{
	// normal
	this->pEngine->GetGraphics()->PushWorldMatrix();
	this->pMySprite->SetPosition((this->ScreenWidth() / 2.0f), this->ScreenHeight() / 2.0f);
	this->pEngine->GetGraphics()->DrawSprite(this->pMySprite);
	this->pEngine->GetGraphics()->SetModelViewMatrix(Matrix::Identity());
	this->pEngine->GetGraphics()->PopWorldMatrix();

	// rotated
	this->pEngine->GetGraphics()->PushWorldMatrix();
	this->pMySprite->SetPosition((this->ScreenWidth() / 2.0f) - (this->pMySprite->GetWidth() + 150.0f), this->ScreenHeight() / 2.0f);
	this->pMySprite->SetRotation(23.0f);
	this->pEngine->GetGraphics()->DrawSprite(this->pMySprite);
	this->pEngine->GetGraphics()->SetModelViewMatrix(Matrix::Identity());
	this->pMySprite->SetRotation(0);
	this->pEngine->GetGraphics()->PopWorldMatrix();

	// scaled
	this->pEngine->GetGraphics()->PushWorldMatrix();
	this->pMySprite->SetPosition((this->ScreenWidth() / 2.0f) + (this->pMySprite->GetWidth() + 150.0f), this->ScreenHeight() / 2.0f);
	this->pMySprite->SetScale(2.0f, 2.0f);
	this->pEngine->GetGraphics()->DrawSprite(this->pMySprite);
	this->pEngine->GetGraphics()->SetModelViewMatrix(Matrix::Identity());
	this->pMySprite->SetScale(1.0f, 1.0f);
	this->pEngine->GetGraphics()->PopWorldMatrix();
}

void MyScreen::Update(float fDelta)
{
	this->pMySprite->Update(fDelta);
}

void MyScreen::Load()
{
	this->pMyTexture = this->pEngine->GetGraphics()->LoadTexture("media/animation.jpg");

	this->pMySprite = new Sprite(this->pMyTexture, 96, 96);		// We create a sprite using the texture
	this->pMySprite->SetHandlePosition(0.5f, 0.5f);				// By setting the handle to .5 the sprite will be
																// rendered centered about its self.
}

void MyScreen::Unload()
{
	this->pEngine->GetGraphics()->UnloadTexture(this->pMyTexture);

	delete this->pMySprite;
}